const express = require('express'); // 引入express
const cors = require('cors'); // 引入cors
const app = express();
const Cityogic = require('../../logic/cityLogic');

// 使用cors解决跨域问题
app.use(cors());

// 使用express.json()中间件解析json格式的请求体
app.use(express.json());

// 获取资源信息
app.get('/getResourcesInfo', (req, res) => Cityogic.getResourcesInfo(req, res));

// 获取周围block数据
app.get('/getBlockData', (req, res) => Cityogic.getBlockData(req, res));

exports.start = (config) => {
    app.listen(config.CLIENT_PORT, () => {
        console.log(`User server is running on port ${config.CLIENT_PORT}`);
    })
}